//package com.lsh.config.dao;
//
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.jdbc.DataSourceBuilder;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//
//import javax.sql.DataSource;
//
///**
// * @author ：LiuShihao
// * @date ：Created in 2020/6/23 8:59 上午
// * @desc ：
// */
//@Configuration
//@MapperScan(basePackages = "com.lsh.dao.db2", sqlSessionFactoryRef = "test2SqlSessionFactory")
//public class DataSourceConfig2 {
//    public  DataSourceConfig2(){
//        System.out.println("数据源2222222222");
//    }
//
//    /**
//     * 配置数据源
//     * @return
//     */
//    @Bean(name = "test2DataSource")
//    @ConfigurationProperties(prefix = "spring.datasource.db2")
//    public DataSource getDateSource2() {
//        return DataSourceBuilder.create().build();
//    }
//
//    /**
//     * 配置数据源工厂
//     * @param datasource
//     * @return
//     * @throws Exception
//     */
//    @Bean(name = "test2SqlSessionFactory")
//    public SqlSessionFactory test2SqlSessionFactory(@Qualifier("test2DataSource") DataSource datasource)
//            throws Exception {
//        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
//        bean.setDataSource(datasource);
//        bean.setMapperLocations(
//                new PathMatchingResourcePatternResolver().getResources("mybatis/mapper/db2/**.xml"));
//        return bean.getObject();
//    }
//
//    /**
//     * 配置数据源工厂模板
//     * @param sessionfactory
//     * @return
//     */
//    @Bean("test2SqlSessionTemplate")
//    public SqlSessionTemplate test2sqlsessiontemplate(
//            @Qualifier("test2SqlSessionFactory") SqlSessionFactory sessionfactory) {
//        return new SqlSessionTemplate(sessionfactory);
//    }
//}
